package com.itlong.cloud.user.miniprogram;

import com.itlong.cloud.POJO.VO.app.AppUserCacheVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;


/**
 *<desc>
 *     微信小程序的登录版块接口代理
 *</desc>
 *
 * @createDate 2018/11/24.
 */
@FeignClient(name="user-service")
public interface IMiniProgramLoginServiceClient {

    /**
     * <desc>
     *      根据手机号进行注册或登录
     * </desc>
     *
     * @param phoneNo  手机号
     * @return
     * @author Juguang.S
     * @createDate 2018/11/24
     */
    @RequestMapping(path = "/miniProgram/user/login",method = RequestMethod.POST)
    AppUserCacheVO login(@RequestParam("phoneNo") String phoneNo,
                         @RequestParam("openId") String openId,
                         @RequestParam(value = "unionId",required = false) String unionId) throws Exception;

    /**
     * <desc>
     *      校验该用户是否被禁用
     * </desc>
     *
     * @param phoneNo  手机号
     * @return
     * @author Juguang.S
     * @createDate 2019/01/05
     */
    @RequestMapping(path = "/miniProgram/user/getUserStatus",method = RequestMethod.POST)
    Integer getUserStatus(@RequestParam("phoneNo") String phoneNo) throws Exception;

    /**
     * <desc>
     *     退出登录
     * </desc>
     *
     * @param token
     * @return
     * @author Juguang.S
     * @createDate 2018/11/24
     */
    @RequestMapping(path = "/miniProgram/user/loginOut",method = RequestMethod.POST)
    void loginOut(@RequestParam("token") String token) throws Exception;

    /**
     * <desc>
     *      从缓存获取用户信息
     * </desc>
     *
     * @param token
     * @return
     * @author Juguang.S
     * @createDate 2018/11/26
     */
    @RequestMapping(path = "/miniProgram/user/retrieve")
    AppUserCacheVO retrieve(@RequestParam("token")String token);

    /**
     * <desc>
     *     微信小程序登录后缓存用户信息
     * </desc>
     * @param appUserCacheVO
     * @return
     * @author Juguang.S
     * @createDate 2018/11/26
     */
    @RequestMapping(path = "/miniProgram/user/loginCacheUserVO",method = RequestMethod.POST)
    boolean loginCacheUserVO(@RequestBody AppUserCacheVO appUserCacheVO) throws Exception;

    /**
     * <desc>
     *      从缓存获取用户信息 用于校验token是否过期
     * </desc>
     *
     * @param token
     * @return
     * @author Juguang.S
     * @createDate 2020/03/10
     */
    @RequestMapping(path = "/miniProgram/user/retrieveByCheckToken")
    AppUserCacheVO retrieveByCheckToken(@RequestParam("token")String token);
}
